Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
What is the definition of "scope" when we are talking about function hoisting in JavaScript

I am learning JavaScript Function Hoisting, which says "the declaration of functions are moved to the top of their scope". Then I read the definition of "scope" from this doc, it says "A function serves as a closure in JavaScript, and thus creates a scope". So does it mean any functions declared inside a function are moved to the top of that function? I use the following example to test:

foo();

function foo() {
   console.log(too);
   console.log(zoo);
   {
      function too() {console.log("too");}
   }
   function zoo() {console.log("zoo");}
}

The out put is

undefined
ƒ zoo() {console.log("zoo");}

So obviously the declaration of too is not moved to the top of foo. It is actually moved to the top of the block statement inside foo. So what is the exact definition of "scope" when we are talking about function hoisting in JavaScript?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda